﻿using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;

namespace Windows.Infrastructure.Share.Extensions
{
    public static class ObjectExtension
    {
        public static int ToInt(this object obj)
        {
            if (obj == null)
                return 0;
            if (obj is Enum)
                return (int)obj;
            _ = int.TryParse(obj.ToString(), out int number);
            return number;
        }
        public static long ToLong(this object obj)
        {
            if (obj == null)
                return 0;
            if (obj is Enum)
                return (long)obj;
            _ = long.TryParse(obj.ToString(), out long number);
            return number;
        }
    }
}
